-
Notifications
You must be signed in to change notification settings - Fork 4.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Footnotes: autosave is not slashing JSON #53664
Conversation
Size Change: +40 B (0%) Total Size: 1.51 MB
ℹ️ View Unchanged
|
Flaky tests detected in dfd972e. 🔍 Workflow run URL: https://github.com/WordPress/gutenberg/actions/runs/5864772264
|
@@ -243,7 +243,7 @@ function _wp_rest_api_autosave_meta( $autosave ) { | |||
return; | |||
} | |||
|
|||
update_post_meta( $id, 'footnotes', $body['meta']['footnotes'] ); | |||
update_post_meta( $id, 'footnotes', wp_slash( $body['meta']['footnotes'] ) ); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Auto saving still triggers the count()
error for me, but not when I add wp_slash()
to the update in wp_save_footnotes_meta
, e.g.,
update_metadata( 'post', $revision_id, 'footnotes', wp_slash( $footnotes ) );
I guess that's being called as well?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🦶🏻 🎶
Thanks for fixing this! |
* Footnotes: autosave saves decoded JSON * wp_slash * Curly quote * Slash on save and restore
* Footnotes: Fix recursion into updating attributes when attributes is not an object (#53257) * Fix crash by moving editor style logic into a hook with useMemo (#53596) * Move editor style logic into a hook whith useMemo * Remove unnecessary useMemo * Move the whole logic inside the 'useMemo' * Add missing useSelect dep --------- Co-authored-by: George Mamadashvili <georgemamadashvili@gmail.com> * Adding an is_array check before using count in case $footnotes is not countable (#53660) * Footnotes: fix accidental override (#53663) * Footnotes: fix accidental override * Remove double quotes * Footnotes: autosave is not slashing JSON (#53664) * Footnotes: autosave saves decoded JSON * wp_slash * Curly quote * Slash on save and restore * Ensure the preview dropdown popover closes (<16.3) for e2e tests --------- Co-authored-by: Andrew Serong <14988353+andrewserong@users.noreply.github.com> Co-authored-by: Noah Allen <noahtallen@gmail.com> Co-authored-by: George Mamadashvili <georgemamadashvili@gmail.com> Co-authored-by: Ramon <ramonjd@users.noreply.github.com> Co-authored-by: Ella <4710635+ellatrix@users.noreply.github.com> Co-authored-by: ramon <ramonjd@gmail.com>
What?
Fixes #53660, https://core.trac.wordpress.org/ticket/59103
Why?
We're making this mistake:
https://developer.wordpress.org/reference/functions/update_post_meta/#character-escaping
This is what the REST API does:
https://github.com/WordPress/wordpress-develop/blob/trunk/src/wp-includes/rest-api/fields/class-wp-rest-meta-fields.php#L393
How?
Testing Instructions
Testing Instructions for Keyboard
Screenshots or screencast